package com.ssw.core.controller;

import com.ssw.config.MessageProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 孙常胜
 * @CreateTime: 2021/7/23 15:44
 * @Description:生产者
 */
@RestController
@RequestMapping("production")
public class ProductionController {
    @Autowired
    private MessageProducer messageProducer;

    /**
     * 生产数据
     * @param topic
     * @param tags
     * @param text
     * @return
     */
    @RequestMapping("push")
    public boolean callback(String topic, String tags, String text) {
        try {
            messageProducer.sendMessage(topic, tags, text);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
